﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Sinacor.OMM.HealthMonitor.Entity.Router;

namespace Sinacor.OMM.HealthMonitor.Collector.SharedHealthDataMemoryStorage.Router
{
    [Serializable]
    public class RouterShdms : IDisposable
    {
        private static RouterShdms _routerShmds;
        private static Mutex mtx = new Mutex();

        private RouterShdms()
        {

        }

        public static RouterShdms GetSharedStorage()
        {
            mtx.WaitOne();
            if (_routerShmds == null)
            {
                _routerShmds = new RouterShdms();
            }
            mtx.ReleaseMutex();

            return _routerShmds;
        }

        private RouterData _routerData;
        public RouterData RouterDataInfo
        {
            get
            {
                if (_routerData == null)
                    _routerData = new RouterData();

                return _routerData;
            }
        }

        #region IDisposable Members

        public void Dispose()
        {
            _routerShmds = null;
            mtx.Close();
            _routerData = null;
        }

        #endregion
    }
}
